#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <stdalign.h>
#include <tgmath.h>
#include <stdarg.h>

#define NDEBUG
#include <assert.h>

#define LEN 81
#define SWAP(type, a, b)    do {type c=a; a=b; b=c;} while(0)

#define SIZE 10

#define SIX = 6;

#define HAR_MEAN(a, b) 1/((1/(a) + 1/(b))/2)

#define PI (4 * atan(1))

#define RAD_TO_DEG 180/PI

#define DEG_TO_RAD PI/180

typedef struct {
    double x;
    double y;
} Rect_cood;

typedef struct {
    double mod;
    double deg;
} Rect_pol;

Rect_cood calc_by_pol(Rect_pol *);

char * s_gets(char *, int);
void eatline(void);


_Static_assert(sizeof(double) == 2*sizeof(int), "double not twice int size");

int main(void)
{
    Rect_pol rp;
    Rect_cood rc;

    puts("Enter a mod of polar coordinates and a degrees.");
    puts("(enter 0 0 to quit.)");
    while (scanf("%lf%lf", &rp.mod, &rp.deg) == 2 && (rp.mod != 0 || rp.deg != 0)) {
        rc = calc_by_pol(&rp);
        printf("coordinate x:%lf y:%lf.\n", rc.x, rc.y);

        puts("Enter mod and degrees.");
    }

    return 0;
}

Rect_cood calc_by_pol(Rect_pol * rp)
{
    Rect_cood rc;
    double rad = rp->deg * DEG_TO_RAD;
    rc.x = rp->mod * cos(rad);
    rc.y = rp->mod * sin(rad);

    return rc;
}

char * s_gets(char * str, int n)
{
    char * ret_val;
    char * find;

    if ((ret_val = fgets(str, n, stdin))) {
        find = strchr(str, '\n');
        if (find)
            *find = 0;
        else
            while (getchar() != '\n')
                ;
    }

    return ret_val;
}

void eatline(void)
{
    while (getchar() != '\n')
        ;
}
